-
Notifications
You must be signed in to change notification settings - Fork 8.8k
fix(session): sort messages by time.created instead of alphabetical order #7425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jchuder
wants to merge
8
commits into
anomalyco:dev
Choose a base branch
from
jchuder:fix/session-messages-sort-by-time
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1
−1
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
a5c3f07 to
384c171
Compare
659712c to
e41f5a3
Compare
e41f5a3 to
3c2d868
Compare
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes
Session.messages()to sort messages bytime.createdtimestamp instead of relying on alphabetical message ID order.Fixes #7426
Problem
opencode export <session_id>outputs messages in wrong order for long sessions. The first part of the conversation appears in the middle or end of the export.Root cause:
Session.messages()usedresult.reverse()which only reverses the alphabetical order fromStorage.list(). Message IDs are random strings (e.g.,msg_19b9ed*vsmsg_b9946c*), so alphabetical order ≠ chronological order.Fix
Replace
result.reverse()withresult.sort((a, b) => a.info.time.created - b.info.time.created)to ensure messages are always sorted by creation timestamp.How did you verify your code works?
lsp_diagnosticson changed file - no errors